package com.aca.entity;

import lombok.AllArgsConstructor;
import lombok.NoArgsConstructor;
import lombok.ToString;

import javax.persistence.*;
import java.io.Serializable;

@ToString
@NoArgsConstructor
@AllArgsConstructor
@Entity
public class Role implements Serializable {
    //角色名 默认不重名
    private String rname;
    //角色性别
    private String rgender;
    //角色描述
    private String rdesc;
    //所处场景
    private Scene sceneByRsno;

    @Id
    @Column(name = "rname")
    public String getRname() {
        return rname;
    }

    public void setRname(String rname) {
        this.rname = rname;
    }

    @Basic
    @Column(name = "rgender")
    public String getRgender() {
        return rgender;
    }

    public void setRgender(String rgender) {
        this.rgender = rgender;
    }

    @Basic
    @Column(name = "rdesc")
    public String getRdesc() {
        return rdesc;
    }

    public void setRdesc(String rdesc) {
        this.rdesc = rdesc;
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;

        Role role = (Role) o;

        if (rname != null ? !rname.equals(role.rname) : role.rname != null) return false;
        if (rgender != null ? !rgender.equals(role.rgender) : role.rgender != null) return false;
        if (rdesc != null ? !rdesc.equals(role.rdesc) : role.rdesc != null) return false;

        return true;
    }

    @Override
    public int hashCode() {
        int result = rname != null ? rname.hashCode() : 0;
        result = 31 * result + (rgender != null ? rgender.hashCode() : 0);
        result = 31 * result + (rdesc != null ? rdesc.hashCode() : 0);
        return result;
    }

    @ManyToOne
    @JoinColumn(name = "rsno", referencedColumnName = "sno")
    public Scene getSceneByRsno() {
        return sceneByRsno;
    }

    public void setSceneByRsno(Scene sceneByRsno) {
        this.sceneByRsno = sceneByRsno;
    }
}
